let actionCreator = (type, payload) => ({ type, payload });
const a = 1354780454;

export const GET_SONG = id => dispatch => {
    if (id) {
        fetch(`http://106.12.79.128:666/song/detail?ids=${id}`)
            .then(body => body.json())
            .then(res => {
                console.log(res.songs);
                dispatch(actionCreator("SONG_ID", res.songs));
            })
            .catch(err => {
                throw new Error(err);
            });
    }
};
export const GET_SONGURL = id => dispatch => {
    if (id) {
        fetch(`http://106.12.79.128:666/song/url?id=${id}`)
            .then(body => body.json())
            .then(res => {
                console.log(res);
                dispatch(actionCreator("SONG_URL", res.data[0]));
            })
            .catch(err => {
                throw new Error(err);
            });
    }
};
